
/*=========================================
* Author: Administrator
* DateTime:2017/6/23 11:13:56
* Description:$safeprojectname$
==========================================*/

using System.Collections.Generic;
using PureMVC.Patterns;

namespace OrderSystem
{
    /// <summary>
    /// 订单代理类，负责管理订单数据和订单操作逻辑
    /// 继承自PureMVC的Proxy类，维护系统中所有订单信息
    /// </summary>
    public class OrderProxy : Proxy
    {
        public new const string NAME = "OrderProxy";
        /// <summary>
        /// 订单集合，存储系统中所有订单信息
        /// 通过Data属性实现数据访问，返回IList<Order>类型
        /// </summary>
        public IList<Order> Orders
        {
            get { return (IList<Order>)base.Data; }
        }

        /// <summary>
        /// 构造函数，初始化订单代理并创建空订单列表
        /// </summary>
        public OrderProxy( ) : base(NAME , new List<Order>())
        {
            //todo 订单应该自来于顾客
        }

        /// <summary>
        /// 添加新订单到系统
        /// </summary>
        /// <param name="order">要添加的订单对象</param>
        public void AddOrder( Order order )
        {
            order.id = Orders.Count + 1;
            Orders.Add(order);
        }
        /// <summary>
        /// 从系统中移除订单
        /// </summary>
        /// <param name="order">要移除的订单对象</param>
        public void RemoveOrder( Order order  )
        {
            Orders.Remove(order);
        }
    }
}